<% 
var listQueryApi = params.find(item => item.name === 'listQueryApi')
var tableColumns = parseTableColumns(listQueryApi)
var values = parseTableParams(listQueryApi)
var form = parseSearchForm(listQueryApi)
%><template>
  <page-header-wrapper>
    <a-spin :spinning="loading">
      <search-form :columns="searchColumns" :formData="searchForm" @search="handleSearch"></search-form>
      <senior-table ref="seniorTable" :columns="columns" :pagination="null" :border="true" @change="getTableData"></senior-table>
    </a-spin>
  </page-header-wrapper>
  </template>
  <script>
  import SearchForm from '@/components/Form/SearchForm.vue'
  import SeniorTable from '@/components/SeniorPanel/SeniorTable.vue'
  export default {
    components: {
      SearchForm,
      SeniorTable
    },
    mounted () {
      this.getTableData()
    },
    methods: {
      handleSearch () {
        this.getTableData()
      },
      async getTableData () {
        this.loading = true
        try {
          var res = await <% if(listQueryApi) { %><%= listQueryApi.apiMethod.controllerName %>.<%= listQueryApi.apiMethod.name %><% } %> ({<% -%>
            <% for(var i =0;i<values.length;i++) {%>
              <%= values[i] %><%= i < values.length - 1 ? ',' : '' -%>
            <% } %>
          })
          if (res.code === 200) {
            this.tableData = (res.data || []).map((item) => {
              return {
                ...item
              }
            })
            this.$refs.seniorTable.$refs.xTable1.loadData(this.tableData)
          }
        } catch (error) {
          console.log(error)
        } finally {
          this.loading = false
        }
      }
    },
    data () {
      
      return {
        columns: <%- tableColumns %>,
        tableData: [],
        searchColumns: <%- form.searchColumns %>,
        searchForm: <%- form.searchForm %>,
        loading: false
      }
    }
  }
  
  </script>
  <style>
  
  </style>
  